<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="<%=request.getContextPath() %>/Hplus/favicon.ico"> 
    <link href="<%=request.getContextPath() %>/Hplus/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="<%=request.getContextPath() %>/Hplus/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <!-- jqgrid-->
    <link href="<%=request.getContextPath() %>/Hplus/css/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">

    <link href="<%=request.getContextPath() %>/Hplus/css/animate.css" rel="stylesheet">
    <link href="<%=request.getContextPath() %>/Hplus/css/style.css?v=4.1.0" rel="stylesheet">

    <style>
        /* Additional style to fix warning dialog position */

        #alertmod_table_list_2 {
            top: 900px !important;
        }
    </style>
</head>
<body class="gray-bg">
	<input type="hidden" id="form_id" value="${requestScope.form_id }"/>
	<div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5>jQuery Grid Plugin – jqGrid</h5>
                    </div>
                    <div class="ibox-content btn">
                        
                    	<c:forEach items="${btnInfo }" var="item">
                    		<button class="btn btn-w-m btn-info" onclick="${item.onclick}">${item.button_name }</button>
                    	</c:forEach>
                    </div>
                    <div class="ibox-content">
                        <p>&nbsp;</p>
                        <h4 class="m-t">通用列表</h4>


                        <div class="jqGrid_wrapper">
                            <table id="table_list_3"></table>
                            <div id="pager_list_3"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</body>
<!-- 全局js -->
<script src="<%=request.getContextPath() %>/Hplus/js/jquery.min.js?v=2.1.4"></script>
<script src="<%=request.getContextPath() %>/Hplus/js/bootstrap.min.js?v=3.3.6"></script>

<!-- Peity -->
<script src="<%=request.getContextPath() %>/Hplus/js/plugins/peity/jquery.peity.min.js"></script>

<!-- jqGrid -->
<script src="<%=request.getContextPath() %>/Hplus/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
<script src="<%=request.getContextPath() %>/Hplus/js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>
<!-- 自定义js -->
<script src="<%=request.getContextPath() %>/Hplus/js/content.js?v=1.0.0"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/baseUI.js"></script>
<script type="text/javascript"
		src="<%=request.getContextPath()%>/js/layer.js"></script>

<!-- Page-Level Scripts -->
    <script>
    var colNames = [];
    var colModel = [];
    var sql;
    var orderBy;
    modulePath = "${requestScope.modulePath}";
    projectPath = "<%=request.getContextPath() %>";
    
    function getCommonListForm(){
    	var form_id = $("#form_id").val();
    	$.ajax({
    		type:"POST",
    		async:false,
    		url:"<%=request.getContextPath() %>/commonQuery/formQuery",
    		data:{curd_form_id:form_id},
    		dataType:"json",
    		success:function(data){
    			sql = data[0].sql_content;
    			orderBy = data[0].order_by;
    		}
    	});
    }
    
    function getCommonList(){
    	var form_id = $("#form_id").val();
    	$.ajax({
    		type:"POST",
    		async:false,
    		url:"<%=request.getContextPath() %>/commonQuery/listQuery",
    		data:{curd_form_id:form_id},
    		dataType:"json",
    		success:function(data){
    			colNames = eval("("+data[0].colName+")");
    			colModel = eval("("+data[0].colModel+")");
    			
    			
    			
    			$.jgrid.defaults.styleUI = 'Bootstrap';
    			
    			$("#table_list_3").jqGrid({
                    url:"<%=request.getContextPath() %>/commonQuery/dataQuery?sql="+sql+"&orderBy="+orderBy,
                    datatype: 'json',
                    height: "100%",
                    autowidth: true,
                    colNames:colNames,    
                    colModel:colModel,    
                    pager: "#pager_list_3",
                    viewrecords: true,
                    //caption: "jqGrid 示例3",
                    multiselect: true,//复选框 
                    hidegrid: false,
                    jsonReader: {
                        root: "rows",   // json中代表实际模型数据的入口  
                        page: "page",   // json中代表当前页码的数据  
                        total: "total", // json中代表页码总数的数据  
                        records: "records", // json中代表数据行总数的数据 
                        repeatitems: false
                    }
                }).trigger("reloadGrid");
                
                
    		}
    	});
    }
    
    function getBtnInfo(){
    	
    }
    
    
        $(document).ready(function () {

        	getCommonListForm(); 
        	
        	getCommonList();
        });
        
        
       ${requestScope.jsContent}
       
    </script>
</html>